package com.efesco.smssvr;

import com.efesco.smssvr.SmsServiceLocator;
import com.efesco.smssvr.SmsServicePortType;
import com.efesco.smssvr.model.SmsBatchModel;


public class SmsSender {
	private static SmsServicePortType smsPort = null;
	private static SmsSender sender = null;
	private String smsPassword = null;
	private SmsSender() throws Exception
	{
		smsPassword = "mrzhuyqRR";
		if(smsPort==null)
		{

			String smsaddr = "http://172.16.96.101/WfShortMsgService/services/SmsService";
			
			System.out.println("请求的链接："+smsaddr);
			java.net.URL smsURL = new java.net.URL(smsaddr);
			SmsServiceLocator loc = new SmsServiceLocator();
			smsPort = loc.getSmsServiceHttpPort(smsURL);
		}
	}
	//获取发送类实例
	public static SmsSender getSingleInstance() throws Exception
	{
		if(sender==null)
			sender = new SmsSender();
		return sender;
	}
	
	//发送一个批短信任务
	public long sendSmsBatch(SmsBatchModel smsbat) throws java.rmi.RemoteException
	{		
		smsbat.setCaller("WEB");
		return smsPort.sendSmsBatch(smsPassword, smsbat);
	}
	
//	//查询批任务发送状态(含失败短信对象列表和不可发短信对象列表)
//	public SmsBatchStatus queryBatchStatus(long smsbatNo) throws java.rmi.RemoteException
//	{		
//		return smsPort.queryBatchStatus(smsPassword, smsbatNo);
//	}
//	
//	//取消发送//
//	public void cancelSend(long smsbatNo) throws java.rmi.RemoteException
//	{		
//		smsPort.cancelSend(smsPassword, smsbatNo);
//	}
//	
//    //查询批任务发送状态(不含失败短信对象列表和不可发短信对象列表，速度快)
//	public SmsBatchStatus queryBatchStatusNoList(long smsbatNo) throws java.rmi.RemoteException
//	{		
//		return smsPort.queryBatchStatusNoList(smsPassword, smsbatNo);
//	}
//	
//	//发送一个批短信任务，短信内容全都相同//
//	public long sendSmsBatchContent(SmsBatchModel smsbat, String content) throws java.rmi.RemoteException
//	{		
//		smsbat.setCaller("WEB");
//		return smsPort.sendSmsBatchContent(smsPassword, smsbat, content);
//	}
//	
//	//处理指定数据库的短信任务
//	public void dealConfigDbSms(String dbname) throws java.rmi.RemoteException
//	{		
//		smsPort.dealConfigDbSms(smsPassword, dbname);
//	}
//	
//	//获取已配置的数据库名称//
//	public ArrayOfString getDbList() throws java.rmi.RemoteException
//	{		
//		return smsPort.getDbList(smsPassword);
//	}

}
